﻿using OpenQA.Selenium;
using OpenQA.Selenium.Support.PageObjects;

namespace AutomatedAcceptanceTests.PageObjects
{
    public class LoginPageObject : BasePageObject
    {
        [FindsBy(How = How.Id, Using = "UserName")]
        private IWebElement userNameField;

        [FindsBy(How = How.Id, Using = "Password")]
        private IWebElement passwordField;

        [FindsBy(How = How.ClassName, Using = "btn-login")]
        private IWebElement submitButton;

        public LoginPageObject()
        {
            PageUrl = "";
        }
        
        public void EnterUserName(string username)
        {
            userNameField.SendKeys(username);
        }

        public void EnterPassword(string password)
        {
            passwordField.SendKeys(password);
        }

        public void ClickSubmit()
        {
            submitButton.Click();
        }

        public void LoginUser(string userName, string password)
        {
            GoToUrl(BaseUrl);
            EnterUserName(userName);
            EnterPassword(password);
            ClickSubmit();
        }
    }
}